package ui;

import java.awt.Color;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.SwingConstants;

import logic.ACListLogin;

@SuppressWarnings({ "serial" })
public class GlobalLogin extends JPanel {
	JButton buttonLogin;
	JTextField userfield = new JTextField();
	JPasswordField passfield = new JPasswordField();
	JButton loginButton;
	public JLabel notification;
	
	public GlobalLogin() {

	
		setBackground(Color.decode("#3a3a3a"));
		setSize(GlobalScreen.SIZE);
		setLayout(null);

		// LOGO
		ImageIcon bitcoinIcon = new ImageIcon("gfx/bitcoinLogo.png");
		JLabel bitcoinlogo = new JLabel(bitcoinIcon);
		bitcoinlogo.setBounds(300, 60, 200, 200);

		// USER ICON
		ImageIcon userIcon = new ImageIcon("gfx/userSmall.png");
		JLabel username = new JLabel(userIcon, SwingConstants.LEFT);
		username.setBounds(250, 280, 300, 40);
		username.setOpaque(true);
		username.setBackground(Color.decode("#FFFFFF"));

		// USER FIELD
		userfield.setBounds(290, 280, 260, 40);
		userfield.setOpaque(true);
		userfield.setBackground(Color.decode("#FFFFFF"));

		// PASSWORD ICON
		ImageIcon passIcon = new ImageIcon("gfx/lockSmall.png");
		JLabel passwordLabel = new JLabel(passIcon, SwingConstants.LEFT);
		passwordLabel.setBounds(250, 340, 300, 40);
		passwordLabel.setOpaque(true);
		passwordLabel.setBackground(Color.decode("#FFFFFF"));

		// PASSWORD FIELD
		passfield.setBounds(290, 340, 260, 40);
		passfield.setOpaque(true);
		passfield.setBackground(Color.decode("#FFFFFF"));

		// LOGIN BUTTON
		buttonLogin = new JButton("Log in");
		buttonLogin.setIcon(null);
		buttonLogin.setBounds(250, 400, 300, 40);
		buttonLogin.setBackground(Color.decode("#157efb"));
		buttonLogin.setForeground(Color.decode("#FFFFFF"));
		buttonLogin.setContentAreaFilled(false);
		buttonLogin.setBorderPainted(false);
		buttonLogin.setOpaque(true);
		buttonLogin.setActionCommand("buttonLogin");

		// NOTIFICATION
		notification = new JLabel("Incorrect username or password!",
				SwingConstants.CENTER);
		notification.setBounds(0, 480, 800, 50);
		notification.setOpaque(true);
		notification.setForeground(Color.decode("#666364"));
		notification.setBackground(Color.decode("#fcd6e5"));
		notification.setVisible(false);

		// ADDING ALL FIELDS
		add(notification);
		add(username);
		add(passwordLabel);
		add(userfield);
		add(passfield);
		add(buttonLogin);
		add(bitcoinlogo);

	}
	
	

	public void addAcListener(ACListLogin ac) {
		buttonLogin.addActionListener(ac);
	}

	public JTextField getUserfield() {
		return userfield;
	}

	public void setUserfield(JTextField userfield) {
		this.userfield = userfield;
	}

	public JPasswordField getPassfield() {
		return passfield;
	}

	public void setPassfield(JPasswordField passfield) {
		this.passfield = passfield;
	}

}